package com.zhaokuner.parentstarter.ctrladaptor;

import com.zhaokuner.parentstarter.ctrladaptor.http.CtrlAdapterHttpClient;
import com.zhaokuner.parentstarter.ctrladaptor.http.ICtrlAdapterHttpClient;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * Description:ctrl adaptor
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author 赵希坤 zhaoxikun
 * @date 2021/2/13 12:15
 */
@Log4j2
@EnableConfigurationProperties(CtrlAdaptorDomainProperties.class)
@Configuration
public class CtrlAdaptorConfiguration implements ApplicationRunner {

    @Bean
    public CtrlAdaptorInvocationHandler ctrlAdaptorInvocationHandler() {
        return new CtrlAdaptorInvocationHandler();
    }

    @Bean
    public ICtrlAdapterHttpClient ctrlAdapterHttpClient() {
        return new CtrlAdapterHttpClient();
    }

    @Autowired
    private CtrlAdaptorDomainProperties ctrlAdaptorDomainProperties;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("ctrlAdaptorDomainProperties:{}", ctrlAdaptorDomainProperties.getDomain());
    }
}
